#添加日程页面类

from time import sleep
from selenium import webdriver
from selenium.webdriver.common.by import By

#数据
driver = webdriver.Chrome()
driver.maximize_window()
driver.get('http://192.168.1.83/crm')
username = 'zhangsan'   #用户名
password = '123456'      #密码
motif = '喜喜喜喜喜喜'
didian = "会议室"
miaoshu = '加油加油加油加油加油加油加油加油'



#元素定位器
username_locator = (By.NAME,'name')      #登录账号
password_locator = (By.NAME, 'password')  #登录密码
btn_locator = (By.NAME,'submit')        #点击登录按钮

schedule_locator = (By.LINK_TEXT,'日程')    #页面日程
newschedule_locator = (By.LINK_TEXT,'新建日程')   #新建日程
motif_locator = (By.ID,'subject')           #新建日程，主题
fuzeren_locator = (By.ID,'owner_name')  #负责人输入框

xuanzefuzeren_locator = (By.XPATH,'//*[@id="d_content"]/tr[1]/td[1]/input')  #选择admin
fuzerenqueren_locator = (By.XPATH,'/html/body/div[7]/div[3]/div/button[1]')  #点击确定

didian_locator = (By.ID,'venue')  #点击地点框
youjian_locator = (By.XPATH,'/html/body/div[5]/div[2]/div/form/table/tbody/tr[4]/td[4]/input[1]') #通知邮件 是
miaoshu_locator = (By.XPATH,'/html/body/div[5]/div[2]/div/form/table/tbody/tr[6]/td[2]/textarea')  #描述
baocun_locator = (By.XPATH,'/html/body/div[5]/div[2]/div/form/table/tfoot/tr/td[2]/input[1]') #保存按钮

# 操作方法
# 输入用户名
username_element = driver.find_element(*username_locator).send_keys(username)

 # 输入用户名
password_element = driver.find_element(*password_locator).send_keys(password)

 # 点击登录
btn_element = driver.find_element(*btn_locator).click()
sleep(2)

#进入新建日程
schedule_element = driver.find_element(*schedule_locator).click()  #点击日程
newschedule_element = driver.find_element(*newschedule_locator).click() #点击新建日程
sleep(2)
motif_element = driver.find_element(*motif_locator).send_keys(motif)   #输入主题内容
fuzeren_element = driver.find_element(*fuzeren_locator).click() #点击负责人输入框
sleep(1)
xuanzefuzeren_element = driver.find_element(*xuanzefuzeren_locator).click()  #选择admin
sleep(1)
fuzerenqueren_element = driver.find_element(*fuzerenqueren_locator).click()  #点击确定

didian_element = driver.find_element(*didian_locator).send_keys(didian)  #输入地点内容
youjian_element = driver.find_element(*youjian_locator).click()   #点击邮件  是
miaoshu_element = driver.find_element(*miaoshu_locator).send_keys(miaoshu)  #输入描述内容
sleep(2)
baocun_element = driver.find_element(*baocun_locator).click()  #点击保存按钮
sleep(5)

driver.quit()

